import { createStore } from 'vuex';
import { relationResponse } from '/@/api/thingsborad/entity/model/entityModel';

export default createStore({
  state: {
    selectedItemId: '',
    devicesInfo: [] as Record<string, string | number>[], // 新增的 string 类型属性
    // 选中的方案，类型为 relationResponse
    selectedIssue: null as relationResponse | null,
    nodeData: null as relationResponse | null,
    nodeDataByToName: null as { [key: string]: relationResponse } | null,
    selectedDeviceId: '' as string, // 新增的设备 ID 状态
    devicesAttributes: null as Record<string, Record<string, Record<string, any>>> | null, //所有设备的属性
  },
  mutations: {
    SET_SELECTED_ITEM_ID(state, id) {
      state.selectedItemId = id;
    },
    // 新增 mutation 用于设置设备 ID
    SET_SELECTED_DEVICE_ID(state, deviceId: string | null) {
      state.selectedDeviceId = deviceId || ''; // 如果传入 null，设置为空字符串
    },
  },
  getters: {
    selectedItemId: (state) => state.selectedItemId,

    selectedDeviceId: (state) => state.selectedDeviceId,
  },
});
